home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / irsim-9.000 / irsim-9 / src / irsim / cad_dir.c < prev    next >
C/C++ Source or Header  |  1993-01-15  |  2KB  |  71 lines

  1. /* 
  2.  *     ********************************************************************* 
  3.  *     * Copyright (C) 1988, 1990 Stanford University.                     * 
  4.  *     * Permission to use, copy, modify, and distribute this              * 
  5.  *     * software and its documentation for any purpose and without        * 
  6.  *     * fee is hereby granted, provided that the above copyright          * 
  7.  *     * notice appear in all copies.  Stanford University                 * 
  8.  *     * makes no representations about the suitability of this            * 
  9.  *     * software for any purpose.  It is provided "as is" without         * 
  10.  *     * express or implied warranty.  Export of this software outside     * 
  11.  *     * of the United States of America may require an export license.    * 
  12.  *     ********************************************************************* 
  13.  */
  14.  
  15. #ifdef SYS_V
  16. #    include <sys/types.h>
  17. #    include <unistd.h>
  18. #endif
  19. #include <sys/file.h>
  20. #include <stdio.h>
  21. #include <pwd.h>
  22. #include "defs.h"
  23.  
  24.  
  25. public    char    *cad_lib;
  26. public    char    *cad_bin;
  27.  
  28.  
  29. extern    char           *getenv();
  30. extern    struct passwd  *getpwnam();
  31. extern    char           *Valloc();
  32.  
  33.  
  34. public void InitCAD()
  35.   {
  36.     char           *s;
  37.     struct passwd  *pwd;
  38.     int            len;
  39.  
  40.     /* first try CAD_HOME env. variable */
  41.  
  42.     s = getenv( "CAD_HOME" );
  43.     if( s )
  44.       {
  45.     if( access( s, F_OK ) == 0 )
  46.         goto go_it;
  47.       }
  48.  
  49.     /* try "~cad" */
  50.  
  51.     pwd = getpwnam( "cad" );
  52.     s = (pwd) ? pwd->pw_dir : 0;
  53.     if( s )
  54.       {
  55.     if( access( s, F_OK ) == 0 )
  56.         goto go_it;
  57.       }
  58.  
  59.     /* default */
  60.  
  61.     s = "/projects/cad";
  62.  
  63.   go_it :
  64.  
  65.     len = strlen( s );
  66.     cad_lib = Valloc( len + 5, 1 );
  67.     cad_bin = Valloc( len + 5, 1 );
  68.     (void) sprintf( cad_lib, "%s/lib", s );
  69.     (void) sprintf( cad_bin, "%s/bin", s );
  70.   }
  71.